<template>
    <view class="dynamic-content">
        <!-- 固定发布按钮 -->
        <view
            class="create-post-fixed"
            v-if="showPublishButton && content.length === 0"
        >
            <view class="create-post" @click="navigateToPublish()">
                <han-icon name="camera" size="50" />
                <text class="title">点击发布作品</text>
            </view>
        </view>

        <!-- 帖子内容列表（复用 postList 组件） -->
        <postList
            :content="content"
            :isLoading="isLoading"
            :hasMore="hasMore"
        />

        <!-- 空状态提示 -->
        <view v-if="content.length === 0" class="empty-tip">
            {{ emptyText }}
        </view>
    </view>
</template>

<script setup>
import postList from '@/pages/post/subpages/post_list/postList.vue';

defineProps({
    content: {
        type: Array,
        default: () => []
    },
    emptyText: String,
    showPublishButton: Boolean,
    isLoading: {
        type: Boolean,
        default: false
    },
    hasMore: {
        type: Boolean,
        default: false
    }
});

const navigateToPublish = () => {
    uni.navigateTo({
        url: '/pages/post/post'
    });
};
</script>

<style scoped lang="scss">
.dynamic-content {
    padding: 20rpx;
    height: 100%;

    .create-post-fixed {
        position: fixed;
        bottom: 200rpx; /* 根据实际tabbar高度调整 */
        left: 0;
        right: 0;
        z-index: 10;
        display: flex;
        justify-content: center;

        .create-post {
            border-radius: 40rpx;
            padding: 15rpx 20rpx;
            display: flex;
            align-items: center;
            border: 1rpx solid $han-global-border-color;
            background: $han-global-bg-color;

            .title {
                margin-left: 10rpx;
                font-size: $han-font-size-xl;
                color: $han-global-primary-font-color;
            }
        }
    }

    .empty-tip {
        margin-top: 10rpx;
        text-align: center;
        font-size: $han-font-size-lg;
        color: $han-global-secondary-font-color;
    }
}
</style>
